package com.sunshine.config;


import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.flow.FlowRule;
import com.alibaba.csp.sentinel.slots.block.flow.FlowRuleManager;
import org.mybatis.spring.annotation.MapperScan;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableScheduling;

import java.util.ArrayList;
import java.util.List;

@SpringBootApplication
@ComponentScan("com.sunshine")
@MapperScan("com.sunshine.mapper")
@EnableScheduling // 启用定时任务
//@EnableFeignClients(basePackages = "com.sunshine.feignService")

public class payApplication {
    private static final Logger log = LoggerFactory.getLogger(payApplication.class);
    
    public static void main(String[] args) {
        SpringApplication app = new SpringApplication(payApplication.class);
        Environment env = app.run(args).getEnvironment();
        log.info("启动成功！！");
        log.info("测试地址: \thttp://127.0.0.1:{}{}/userpay/hello", env.getProperty("server.port"), env.getProperty("server.servlet.context-path"));
/*        initFlowRules();
        log.info("sentinel启动成功");*/
    }

    @Bean
    public RedissonClient redissonClient() {
        Config config = new Config();
        config.useSingleServer()
                .setAddress("redis://192.168.100.87:6379")  // 使用配置中的 Redis 地址
                .setConnectTimeout(2000)
                .setConnectionPoolSize(8)
                .setConnectionMinimumIdleSize(0);
        return Redisson.create(config);
    }
}